package com.okonna.selenium.tide.workers;

import org.apache.commons.lang3.*;

import com.thoughtworks.selenium.*;

public class RCClientWorker
{
    private Selenium selRCClient;
    
    public RCClientWorker(Selenium tmpSelenium)
    {
		System.out.println(this.getClass().getSimpleName() + ".RCClientWorker(" + tmpSelenium + ")");
		selRCClient = tmpSelenium;
    }

    public void startClient() throws Exception
    {
		System.out.println(this.getClass().getSimpleName() + ".startClient()");
		selRCClient.start();
    }

    public void stopClient() throws Exception
    {
		System.out.println(this.getClass().getSimpleName() + ".stopClient()");
		selRCClient.stop();
    }

    public void openPage(String strURLPath) throws Exception
    {
		System.out.println(this.getClass().getSimpleName() + ".openPage(" + strURLPath + ")");
		selRCClient.open(strURLPath);
    }

    public String dumpText(String strLocator) throws Exception
	{
		System.out.println(this.getClass().getSimpleName() + ".dumpText(" + strLocator + ")");
		try
		{
		    return StringEscapeUtils.escapeJava(selRCClient.getText(strLocator));
		}
		catch (SeleniumException e)
		{
		    return e.getLocalizedMessage();
		}
    }
}
